package pl.prac07;

import java.io.FileInputStream;
import java.io.IOException;

import pl.prac07.Analex;
import pl.prac07.Anasint;
import antlr.ANTLRException;
import antlr.*;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
    	boolean error=false;
        try {
        	System.out.println("Fichero analizado por mi analizador");
            FileInputStream fis = new FileInputStream(args[0]); 
            Analex analex = new Analex(fis);
            //System.out.println(salida);
            /*Anasint anasint = new Anasint(analex); 
            anasint.entrada();*/ 
            FileInputStream fis2 = new FileInputStream(args[0]); 
            Analex analex2 = new Analex(fis2);
            Token token2 = analex2.nextToken();
            while(token2.getType() != Token.EOF_TYPE) {
            	System.out.println(token2);
                token2 = analex2.nextToken();
                System.out.print("");    
            }
            
          }

          catch(ANTLRException ae) {
             System.err.println(ae.getMessage());
             System.out.println("Error");
             error = true;
          }

          catch(IOException ioe) {
             System.err.println(ioe.getMessage());
          }
          if (error == false)
        	  System.out.println("Fichero OK");
          else {
        	  System.out.println("Fichero No OK");
        	  error=false;
          }
    }
}
